package com.mercadoutils.controller;

import java.io.IOException;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mercadolibre.sdk.AuthorizationFailure;
import com.mercadolibre.sdk.Meli;
import com.mercadolibre.sdk.MeliException;
import com.mercadoutils.domain.Category;
import com.mercadoutils.listeners.SesionListener;


@Controller
public class CategoryController {
	
	@RequestMapping("/category.html")
	 public @ResponseBody String doRedirect(Model model, 
			 				  @RequestParam(value="id",required=false,defaultValue="") String id)
			 				  throws AuthorizationFailure, MeliException, IOException
	 {
		HttpSession session = SesionListener.getSession();
        Meli m = (Meli) session.getAttribute("meli");
//        model.addAttribute("html",Category.updateCategorias(m, "MLA1100"));
        return Category.updateCategorias(m, id);
	 }

}
